1. Field of the Invention
The present invention relates to a calculation device and method.
Priority is claimed on Japanese Patent Application No. 2010-220156, filed Sep. 30, 2010, the content of which is incorporated herein by reference.
2. Description of the Related Art
All patents, patent applications, patent publications, scientific articles, and the like, which will hereinafter be cited or identified in the present application, will hereby be incorporated by reference in their entirety in order to describe more fully the state of the art to which the present invention pertains.
A predetermined rectangular area is set for image data in which pixels are arranged in a two-dimensional matrix. Image processing such as filtering of image data is performed by integrating values of pixels within the rectangular area while shifting the rectangular area pixel by pixel in horizontal and vertical directions. FIGS. 10A to 10D are diagrams schematically showing a state in which a rectangular area is shifted in image processing performed by integrating pixel values while shifting the rectangular area in accordance with the related art. FIG. 10A shows a state in which a rectangular area R of which pixel values are integrated is shifted pixel by pixel in the horizontal direction. FIG. 10B shows a state in which the rectangular area R is shifted by one row in the vertical direction after an integration of pixel values for one row of image data is completed, that is, after the rectangular area R is shifted to a position of the last pixel of a first row of the image data. FIG. 10C shows a state in which the rectangular area R is re-shifted pixel by pixel in the horizontal direction after the rectangular area R is shifted by one row in the vertical direction. In image processing to be performed while the rectangular area is shifted as described above, the predetermined rectangular area R is shifted pixel by pixel in the horizontal and vertical directions as shown in FIGS. 10A to 10C. When the position of the rectangular area R is shifted to a position of the last pixel of the last row of the image data as shown in FIG. 10D, the integration of values of pixels within the rectangular area R is completed.
In the image processing as described above, the following methods are used to integrate values of pixels within a predetermined rectangular area. For example, there is a method of preparing line memories corresponding in number to a height of the rectangular area and performing an integration process for pixel values stored in the line memories. In this method, the rectangular area is sequentially shifted in the vertical direction while data of the line memory unused in the integration process is rewritten to data of a row for which the next integration process is performed by the line memory. In the configuration as described above, the height of the rectangular area for which the integration process can be performed is limited to a height corresponding to the number of prepared line memories. Because it is necessary to prepare more line memories so as to reduce the limit of the height of the rectangular area, the circuit scale is increased.
Further, for example, there is a method of performing an integration process while reading values of pixels within a rectangular area to be integrated from a line memory storing image data every time. In this method, the limit on the height of the rectangular area can be eliminated. In this method, image data is read every time so as to acquire values of pixels within a rectangular area for which the integration process is performed. Thus, the number of memory accesses to the memory storing image data is large and hence the integration process is time-consuming.
As a technique of the integration process, for example, Japanese Unexamined Patent Application, First Publication No. 2004-185611 discloses a method of integrating image data using an integral image. The integral image has a feature that each pixel value is a cumulative value of a rectangular area from the origin. In Japanese Unexamined Patent Application, First Publication No. 2004-185611, the feature is maintained and the integral image is used in an integration process for the rectangular area.
Here, an integral image and an integration process within a predetermined rectangular area using the integral image will be described. FIGS. 11A and 11B are schematically diagrams showing examples of image data and an integral image based on the image data. FIGS. 12A and 12B are diagrams illustrating a processing method for an integration process using an integral image.
The integral image is data in which a position of a predetermined pixel of the image data is designated as the origin and a sum of values of all pixels within a rectangular area where the origin is diagonal to a position of a target pixel (or where pixels are located on both ends) is designated as a target pixel value. FIG. 11A shows image data of 6 rows and 6 columns, and FIG. 11B shows an integral image for the image data of the 6 rows and the 6 columns shown in FIG. 11A. The integral image shown in FIG. 11B is an integral image in which a sum of values of pixels, within a rectangular area having a pixel of a first column of a first row of the image data shown in FIG. 11A as the origin, is regarded as each pixel value. For example, a value “18”, which is obtained by a sum of a pixel value “1” of a first column of a first row, a pixel value “2” of a second column of the first row, a pixel value “7” of a first column of a second row, and a pixel value “8” of a second column of the second row, is regarded as the pixel value of the second column of the second row.
Using the integral image, it is possible to easily obtain integration values of all pixels within a predetermined rectangular area from values of pixels within a rectangular area including the predetermined rectangular area from which the integration values are obtained and pixel values within rectangular areas in contact with the predetermined rectangular area. More specifically, for example, an integration value of all pixels within a rectangular area R in image data shown in FIG. 12A may be obtained. In this case, as shown in FIG. 12B, an integration value of all pixels within the rectangular area R is obtained by the following Equation (1) from a value of a pixel on the diagonal to the origin within a rectangular area A including the rectangular area R and values of pixels on the diagonal to the origin within a rectangular area B, a rectangular area C, and a rectangular area D in contact with the rectangular area R.r=a−b−c+d  (1)
In the above Equation (1), r denotes an integration value of all pixels within the rectangular area R, a denotes a value of a pixel on the diagonal to the origin in the rectangular area A, b denotes a value of a pixel on the diagonal to the origin in the rectangular area B, c denotes a value of a pixel on the diagonal to the origin in the rectangular area C, and d denotes a value of a pixel on the diagonal to the origin in the rectangular area D.
A calculation is carried out based on pixel values within the image data and pixel values within the integral image shown in FIGS. 12A and 12B. An integration value of the rectangular area R in the image data of FIG. 12A becomes 15+16+17+21+22+23+27+28+29=198. If the integration value of the rectangular area R is obtained by the above Equation (1) from the pixel values within the integral image of FIG. 12B, 375−135−60+18=198. As described above, it is possible to easily obtain integration values of all pixels of a specific rectangular area by use of an integral image.
A storage capacity of a memory becomes significantly large so as to expand and store an integral image corresponding to image data in the memory. For example, an integral image corresponding to one image data obtained by capturing a moving image may be stored in a memory in an image capturing device such as a still-image camera, a moving-image camera, a medical endoscope camera, or an industrial endoscope camera. In this case, in the image data of the moving image, one pixel is 8 bits (1 byte), 640 pixels are in a row direction, and 480 pixels are in a column direction. If an integral image corresponding to one image data is simply stored in the memory, a memory storage capacity per pixel necessary to store a total of pixels is 1 (byte)×640 (pixels)×480 (pixels)=307.2 (kilobytes). A memory storage capacity of one page of the image data of the moving image becomes 307.2 (kilobytes)×640 (pixels)×480 (pixels)=94.37 (gigabytes).
As described above, a memory of a large storage capacity is necessary to simply store an integral image corresponding to image data. It is inefficient to prepare such a memory having large storage capacity in advance. Thus, it is difficult to pre-expand an integral image in a memory in order to perform an integration process.